<template>
  <div class="yun-head">
    <div class="yun-logo">浮生一滴泪</div>
    <div class="yun-user">
      <div class="user-name">{{ store.userInfo.name }}</div>
      <div class="user-logout" @click="logoutEvent">
        <el-icon color="#fff" size="16"><SwitchButton /></el-icon>
      </div>
    </div>
  </div>
</template>

<script setup>
import {logout} from '@/api/index.js'
import {useUserStore} from '@/store/userStore'
import {useRouter} from 'vue-router'
const store = useUserStore()
const router = useRouter()
const logoutEvent =async ()=>{
  ElMessageBox.confirm('是否确认退出系统','提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }).then(async ()=>{
      await logout()
      localStorage.clear()
      router.push('/login')
    })
}
</script>

<style lang="scss" scoped>
.yun-head{
  width:100%;
  height:60px;
  padding:0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--main-color);
  .yun-logo{
    font-size:24px;
    line-height: 60px;
    color:#fff;
  }
  .yun-user{
    display: flex;
    align-items: center;
    color:#fff;
    .user-name{
      margin-right:10px;
    }
    .user-logout{
      cursor: pointer;
    }
    
  }
}
</style>